Skip to content

Instantly share code, notes, and snippets.

View marketinview's full-sized avatar

Market In View marketinview

View GitHub Profile
@marketinview
marketinview / carouselExclusive.html
Last active March 6, 2024 16:02
Qualtrics: Carousel Exclusive Scale Points. Make scale point exclusive by placing its label inside an element with class "exclusive". #qualtrics #js #jq #carousel #exclusive
<span class="exclusive">Scale Point Label</span>
@marketinview
marketinview / choicesToList.js
Last active February 6, 2024 16:10
Qualtrics: MC choices to list. Use to present an unordered (bullets) or ordered (numbered) randomized list of items. #qualtrics #js #jq #random #list #bullets #numbered
Qualtrics.SurveyEngine.addOnload(function() {
var listType = "ul"; //use ul for unorderd list, ol for ordered list
var q = jQuery(this.questionContainer);
q.find(".QuestionBody").hide();
q.find(".QuestionText").append("<"+listType+" class='choiceList'></"+listType+">");
var list = q.find(".choiceList").css("margin-bottom","0px");
q.find("label.SingleAnswer>span").each(function() { list.append("<li>"+this.innerHTML+"</li>"); });
});
@marketinview
marketinview / likertScaleVertical.html
Last active September 28, 2023 13:39
Qualtrics: Likert Scales Vertical #qualtrics #css #matrix #likert #scale #vertical #answers
<style>
.Skin .Matrix table tr.ChoiceRow td {
display:block;text-align:left;padding:5px 2px;border-left:1px solid #666;border-right:1px solid #666; }
.Skin .Matrix table th.c1 { border-left:1px solid #666;border-bottom:1px solid #666; }
.Skin .Matrix table tr.ChoiceRow td:last-of-type { border-bottom:1px solid #666; }
.Skin .Matrix table tr.ChoiceRow:first-of-type th,
.Skin .Matrix table tr.ChoiceRow:first-of-type td:first-of-type { border-top:1px solid #666; }
.JFEScope .Skin .desktop .mobile { display: inline!important; }
tr.Answers { display:none; }
.JFEScope .Skin .desktop .mobile.dropdown-arrow { display:none!important; }
@marketinview
marketinview / ageFromDOB.header.html
Created August 28, 2023 15:01
Qualtrics: Age from Date of Birth #qualtrics #js #jq #age #birthdate #dob #luxon
<script src="https://cdn.jsdelivr.net/npm/luxon@3.4/build/global/luxon.min.js"></script>
@marketinview
marketinview / qualtrics.array.from.polyfill.js
Created August 25, 2023 14:04
Qualtrics: Replace Qualtrics Array.from Polyfill with one that supports iterables #qualtrics #js #polyfill #array #from
Qualtrics.SurveyEngine.addOnload(function() {
console.log(Array.from({length: 20}, (e, i) => i));
});
// Production steps of ECMA-262, Edition 6, 22.1.2.1
// Copied and modified from http://www.devdoc.net/web/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from.html
Array.from = (function () {
var toStr = Object.prototype.toString;
var isCallable = function (fn) {
return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
@marketinview
marketinview / bipolarLeftRightRandomize.js
Created November 29, 2022 22:40
Qualtrics: Randomize Bipolar Left/Right Statements. Turn off Mobile Friendly (it is useless anyway). #qualtrics #js #jq #bipolar #random
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .ChoiceRow").each(function() {
if(Math.random() < 0.5) {
var row = jQuery(this);
row.children().each(function() { row.prepend(jQuery(this)); });
row.find("th").first().removeClass("AnswerLeft").addClass("AnswerRight");
row.find("th").last().removeClass("AnswerRight").addClass("AnswerLeft");
}
});
});
@marketinview
marketinview / sbsRandomizeSelects.js
Last active October 27, 2022 12:39
Qualtrics: Randomize Side-by-side Selects #qualtrics #js #jq #sbs #select #random
Qualtrics.SurveyEngine.addOnload(function() {
var selector = "select"; //Update for specific selects
jQuery(this.questionContainer).find(selector).each(function() {
var sel = jQuery(this);
var options = sel.find("option:not(:first)").toArray();
for(var i=0;i<=options.length;i++) { sel.append(options[Math.random() * i | 0]); }
});
});
@marketinview
marketinview / resetMatrix.html
Last active October 23, 2022 13:58
Qualtrics: Reset Likert Matrix. Works with single or multi-select matrix. Add button html to question text. #qualtrics #js #jq #matrix #likert #reset
<button class="reset">Reset</button>
@marketinview
marketinview / convertPipedChoicesToBullets.html
Last active January 13, 2023 17:59
Quatrics: Convert Piped Choices to Bullets. #qualtrics #js #jq #pipe #bullets
Show a bulleted list here: <div class="bullets">${q://QID84/ChoiceGroup/SelectedChoices}</div>
@marketinview
marketinview / uuidv4.js
Created January 31, 2021 21:18
uuid - JavaScript function to create uuid. From: https://stackoverflow.com/a/2117523/4434072 #js #uuid #id
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
}
console.log(uuidv4());